<?php
/**
 * 深交所方法
 */
namespace App\Models\Authority\Other;

use App\Models\Authority\Other\OtherLog;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Closure;
use Mockery\CountValidator\Exception;

class sjsMethod 
{
    public static function regSJC($username)
    {
        $oLog=new OtherLog();
        $oLog->id=getuuID();
        $oLog->other_name='sjs';
        $oLog->other_url='http://yibao.jumafeiteng.com/api/register';

        try{
            if (strpos($username, 'cxh') !== false) {
                $data = array();
                $data['username'] = $username;
                $data['req_time'] = time();
                $data['company'] = 'jmft';
                $data['referer'] = 'cxh000001';
                $data['sign'] = md5($data['username'] . $data['req_time'] . $data['company'] . $data['referer'] . '532D4B05340D0DC6');

                $curl = curl_init();
                curl_setopt($curl, CURLOPT_TIMEOUT, 15);
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($curl, CURLOPT_URL, 'http://yibao.jumafeiteng.com/api/register');
                // curl_setopt($curl, CURLOPT_HTTPHEADER, 1);
                curl_setopt($curl, CURLOPT_POST, true);
                curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
                $result = curl_exec($curl);
                $retDate= json_decode($result, true);

                $oLog->postData=json_encode($data);
                $oLog->returnData=$retDate;
            }
        }
        catch(Exception $ex){
            $oLog->errorData=$ex->getMessage();
        }

        $oLog->save();
    }
}